const encryption = require("../util/encryption")
const db = require("../lib/conn_oracle")

exports.psToDb = async (un,ps) => {
    console.log(ps)
    encryption.hashedPassword(ps)
    let hasPs = await encryption.hashedPassword(ps)
    console.log(hasPs)
    let resStatus = 0
    let resData
    let addDatas = [999998,un,'系统管理员',hasPs,'','50421207',1]
    let handleSql = `insert into c##wxw.vue_xfjcusers(id,personid,username,realname,password,remark,persongroup,status)
                    values('',:PERSONID,:USERNAME,:REALNAME,:PASSWORD,:REMARK,:PERSONGROUP,:STATUS)
                    ` 
    try{
        let resAa = await db.writeTab(handleSql,addDatas)
        resStatus = resAa.errorNum ? 0 : 1
        resData = {resAa,resStatus}
    }catch(err){
        resStatus = 0 
        resData =  {err,resStatus}
    }finally{
        return resData
    }

}